//
//  EvaluationViewController.m
//  SchoolProduct
//
//  Created by 蒋松涵 on 16/9/8.
//  Copyright © 2016年 sm. All rights reserved.
//

#import "EvaluationViewController.h"

@interface EvaluationViewController ()<UITableViewDataSource,UITableViewDelegate,UITextViewDelegate>

{
    NSString *leaveWord;

}
@property(nonatomic,strong)UITableView * tableView;
@property(nonatomic,strong)NSMutableArray * dataArray;
@property (nonatomic,retain) UITextView *textView;//其他建议


@property(nonatomic,strong)NSString * years;//学年
@property(nonatomic,strong)NSString * KeChengName;//课程
@property(nonatomic,strong)NSString * teacher;//教师
@property(nonatomic,strong)NSString * jiaoxuelou;//教学楼
@property(nonatomic,strong)NSString * cengshu;//楼层
@property(nonatomic,strong)NSString * jiaoshi;//教室
@property(nonatomic,strong)NSString * Number;//已评价人数
@property(nonatomic,strong)NSString * number;//总评价数


@end

@implementation EvaluationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"课程评价";
    self.view.backgroundColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1];
    
    [self init_TableView];
    
}

#pragma mark - UITableView----------
-(void)init_TableView
{
    self.tableView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.scrollEnabled = NO;
    [self.view addSubview:self.tableView];
}

#pragma mark - UITableViewDataSource----------
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString * CellIdentifier = @"cell";
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
    cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
    cell.selectionStyle = UITableViewCellAccessoryNone;
    
    switch (indexPath.row) {
        case 0:
        {
            UILabel * dataLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, 15, 150, 30)];
            dataLabel.text = @"2015-2016学年";
            [cell.contentView addSubview:dataLabel];
        }
            break;
        case 1:
        {
            UILabel * dataLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, 10, 150, 30)];
            dataLabel.text = @"色彩构成";
            [cell.contentView addSubview:dataLabel];
            
            UIImageView * images = [[UIImageView alloc]initWithFrame:CGRectMake(20, 60, 20, 20)];
            images.image = [UIImage imageNamed:@"其他小图标-06.png"];
            [cell.contentView addSubview:images];
            
            UILabel * teacherLabel = [[UILabel alloc]initWithFrame:CGRectMake(60, 55, 100, 30)];
            teacherLabel.text = @"王雷";
            [cell.contentView addSubview:teacherLabel];
            
            UIImageView * image_ = [[UIImageView alloc]initWithFrame:CGRectMake(200, 60, 20, 20)];
            image_.image = [UIImage imageNamed:@"其他小图标-07.png"];
            [cell.contentView addSubview:image_];
            
            UILabel * schoolRoomLabel = [[UILabel alloc]initWithFrame:CGRectMake(240, 55, 100, 30)];
            schoolRoomLabel.text = @"1号教学楼";
            [cell.contentView addSubview:schoolRoomLabel];
            
            
        }
            
            break;
        case 2:
        {
            UILabel * pingjiaLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, 10, 150, 30)];
            pingjiaLabel.text = @"评价人数";
            [cell.contentView addSubview:pingjiaLabel];
            
            UILabel * numberLabel = [[UILabel alloc]initWithFrame:CGRectMake(170, 10, 150, 30)];
            numberLabel.text = @"28/60";
            [cell.contentView addSubview:numberLabel];
            
        }
            break;
        case 3:
        {
            UILabel * label1 = [[UILabel alloc]initWithFrame:CGRectMake(20, 10, 150, 30)];
            label1.text = @"教学态度";
            [cell.contentView addSubview:label1];
            
            UILabel * label2 = [[UILabel alloc]initWithFrame:CGRectMake(20, 40, 150, 30)];
            label2.text = @"教学内容";
            [cell.contentView addSubview:label2];
            
            UILabel * label3 = [[UILabel alloc]initWithFrame:CGRectMake(20, 70, 150, 30)];
            label3.text = @"教学方法";
            [cell.contentView addSubview:label3];
            
            UILabel * label4 = [[UILabel alloc]initWithFrame:CGRectMake(20, 100, 150, 30)];
            label4.text = @"教学效果";
            [cell.contentView addSubview:label4];
            
            UILabel * label5 = [[UILabel alloc]initWithFrame:CGRectMake(20, 130, 150, 30)];
            label5.text = @"学术水平";
            [cell.contentView addSubview:label5];
            
        }
            break;
        case 4:
        {
            UILabel * label1 = [[UILabel alloc]initWithFrame:CGRectMake(20, 10, 150, 30)];
            label1.text = @"其他建议";
            [cell.contentView addSubview:label1];
            
            _textView = [[UITextView alloc] initWithFrame:CGRectMake(25, 40, cell.frame.size.width, 150)];
            _textView.backgroundColor=[UIColor lightGrayColor]; //背景色
            _textView.scrollEnabled = NO;    //当文字超过视图的边框时是否允许滑动，默认为“YES”
            _textView.editable = YES;        //是否允许编辑内容，默认为“YES”
            _textView.delegate = self;       //设置代理方法的实现类
            _textView.font=[UIFont fontWithName:@"Arial" size:18.0]; //设置字体名字和字体大小;
            _textView.returnKeyType = UIReturnKeyDefault;//return键的类型
            _textView.keyboardType = UIKeyboardTypeDefault;//键盘类型
            _textView.textAlignment = NSTextAlignmentLeft; //文本显示的位置默认为居左
            _textView.dataDetectorTypes = UIDataDetectorTypeAll; //显示数据类型的连接模式（如电话号码、网址、地址等）
            _textView.scrollEnabled = YES;
            _textView.textColor = [UIColor grayColor];
            //textview.text = self.textVi_.text
            
            
            if(leaveWord.length == 0)
            {
                _textView.text = @"对于该课程或者授课老师的其他意见或建议";//设置显示的文本内容
            }
            else
            {
                _textView.textColor = [UIColor blackColor];
                _textView.text = leaveWord;//设置显示的文本内容
            }
            
            [cell.contentView addSubview:_textView];
            
            UIButton * TiJiaoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
            TiJiaoBtn.frame = CGRectMake(cell.frame.size.width / 2, 200, 80, 40);
            TiJiaoBtn.backgroundColor = [UIColor orangeColor];
            [TiJiaoBtn setTitle:@"提交" forState:UIControlStateNormal];
            [TiJiaoBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [TiJiaoBtn addTarget:self action:@selector(tijiaoBtnClick) forControlEvents:UIControlEventTouchUpInside];
            [cell.contentView addSubview:TiJiaoBtn];
        }
            break;
        default:
            break;
    }

    
    return cell;
}

#pragma mark - UITableView的高度----------
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    switch (indexPath.row) {
        case 0:
        {
            return 40;
        }
            break;
        case 1:
        {
            return 90;
        }
            break;
        case 2:
        {
            return 40;
        }
            break;
        case 3:
        {
            return 180;
        }
            break;
        case 4:
        {
            return 250;
        }
            break;
        default:
            break;
    }
    return 0;
}

-(void)textViewDidBeginEditing:(UITextView *)textView
{
    _tableView.frame = CGRectMake(0, -280, self.view.frame.size.width, self.view.frame.size.height);
    textView.textColor = [UIColor blackColor];
    if(leaveWord.length == 0)
    {
        textView.text = @"";//设置显示的文本内容
    }
    else
    {
        textView.text = leaveWord;//设置显示的文本内容
    }
    
    
}

//
-(void)tijiaoBtnClick
{
    NSLog(@"你点击提交了");
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
